<template>
  <div id="homeIndex">
    <div v-for="item in items" :key="item.id">
      <span>{{ item.id }} </span>
      <span>{{ item.name }} </span>
      <span>{{ item.age }} </span>
    </div>
  </div>
</template>

<script>
import { getMockData } from "../api/home";
export default {
  name: "homeIndex",
  component: { getMockData },
  data() {
    return {
      items: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      let param = { name: "杜恒" };
      getMockData(param).then((res) => {
        if (res) {
          // this.items = eval("(" + res.data + ")");
          this.items = res;
          console.log(res);
        } else {
          console.log("获取数据失败");
        }
      });
    },
  },
};
</script>
<style></style>
